Clover Coverage Report - EasyMock Parent 3.1 (Aggregated)
Coverage timestamp: jeu. nov. 10 2011 02:12:55 CET
../../img/srcFileCovDistChart10.png 0% of files have more coverage
271   2 258   154   1,78
4   625   0,57   152
152     1,01  
1    
0,2% of code in this file is excluded from these metrics.
 
  EasyMock       Line # 31 271 0,2% 154 0 100% 1.0
 
  (2032)
 
1    /**
2    * Copyright 2001-2011 the original author or authors.
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    * http://www.apache.org/licenses/LICENSE-2.0
9    *
10    * Unless required by applicable law or agreed to in writing, software
11    * distributed under the License is distributed on an "AS IS" BASIS,
12    * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13    * See the License for the specific language governing permissions and
14    * limitations under the License.
15    */
16    package org.easymock;
17   
18    import java.lang.reflect.Method;
19    import java.util.Comparator;
20   
21    import org.easymock.internal.*;
22    import org.easymock.internal.matchers.*;
23   
24    /**
25    * Main EasyMock class. Contains methods to create, replay and verify mocks and
26    * a list of standard matchers.
27    *
28    * @author OFFIS, Tammo Freese
29    * @author Henri Tremblay
30    */
 
31    public class EasyMock {
32   
33    /**
34    * Since EasyMock 2.4, by default, a mock wasn't allowed to be called in
35    * multiple threads unless it was made thread-safe (See
36    * {@link #makeThreadSafe(Object, boolean)} method). Since EasyMock 2.5,
37    * this isn't the default anymore. For backward compatibility, this property
38    * can bring EasyMock 2.4 behavior back.
39    */
40    public static final String ENABLE_THREAD_SAFETY_CHECK_BY_DEFAULT = "easymock.enableThreadSafetyCheckByDefault";
41   
42    /**
43    * Since EasyMock 2.5, by default a mock is thread-safe. For backward
44    * compatibility, this property can change the default. A given mock still
45    * can be made thread-safe by calling
46    * {@link #makeThreadSafe(Object, boolean)}.
47    */
48    public static final String NOT_THREAD_SAFE_BY_DEFAULT = "easymock.notThreadSafeByDefault";
49   
50    /**
51    * Since EasyMock 3.0, EasyMock can perform class mocking directly without
52    * using the class extension. If you want to disable any class mocking, turn
53    * this to true.
54    */
55    public static final String DISABLE_CLASS_MOCKING = "easymock.disableClassMocking";
56   
57    /**
58    * Creates a mock object that implements the given interface, order checking
59    * is enabled by default.
60    *
61    * @param <T>
62    * the interface that the mock object should implement.
63    * @param toMock
64    * the class of the interface that the mock object should
65    * implement.
66    * @return the mock object.
67    */
 
68  245 toggle public static <T> T createStrictMock(final Class<T> toMock) {
69  245 return createStrictControl().createMock(toMock);
70    }
71   
72    /**
73    * Creates a mock object that implements the given interface, order checking
74    * is enabled by default.
75    *
76    * @param name
77    * the name of the mock object.
78    * @param toMock
79    * the class of the interface that the mock object should
80    * implement.
81    * @param <T>
82    * the interface that the mock object should implement.
83    * @return the mock object.
84    * @throws IllegalArgumentException
85    * if the name is not a valid Java identifier.
86    */
 
87  17 toggle public static <T> T createStrictMock(final String name, final Class<T> toMock) {
88  17 return createStrictControl().createMock(name, toMock);
89    }
90   
91    /**
92    * Creates a mock object that implements the given interface, order checking
93    * is disabled by default.
94    *
95    * @param <T>
96    * the interface that the mock object should implement.
97    * @param toMock
98    * the class of the interface that the mock object should
99    * implement.
100    * @return the mock object.
101    */
 
102  1455 toggle public static <T> T createMock(final Class<T> toMock) {
103  1455 return createControl().createMock(toMock);
104    }
105   
106    /**
107    * Creates a mock object that implements the given interface, order checking
108    * is disabled by default.
109    *
110    * @param name
111    * the name of the mock object.
112    * @param toMock
113    * the class of the interface that the mock object should
114    * implement.
115    *
116    * @param <T>
117    * the interface that the mock object should implement.
118    * @return the mock object.
119    * @throws IllegalArgumentException
120    * if the name is not a valid Java identifier.
121    */
 
122  22 toggle public static <T> T createMock(final String name, final Class<T> toMock) {
123  22 return createControl().createMock(name, toMock);
124    }
125   
126    /**
127    * Creates a mock object that implements the given interface, order checking
128    * is disabled by default, and the mock object will return <code>0</code>,
129    * <code>null</code> or <code>false</code> for unexpected invocations.
130    *
131    * @param <T>
132    * the interface that the mock object should implement.
133    * @param toMock
134    * the class of the interface that the mock object should
135    * implement.
136    * @return the mock object.
137    */
 
138  118 toggle public static <T> T createNiceMock(final Class<T> toMock) {
139  118 return createNiceControl().createMock(toMock);
140    }
141   
142    /**
143    * Creates a mock object that implements the given interface, order checking
144    * is disabled by default, and the mock object will return <code>0</code>,
145    * <code>null</code> or <code>false</code> for unexpected invocations.
146    *
147    * @param name
148    * the name of the mock object.
149    * @param toMock
150    * the class of the interface that the mock object should
151    * implement.
152    *
153    * @param <T>
154    * the interface that the mock object should implement.
155    * @return the mock object.
156    * @throws IllegalArgumentException
157    * if the name is not a valid Java identifier.
158    */
 
159  17 toggle public static <T> T createNiceMock(final String name, final Class<T> toMock) {
160  17 return createNiceControl().createMock(name, toMock);
161    }
162   
163    /**
164    * Creates a mock object that extends the given class, order checking is
165    * enabled by default.
166    *
167    * @param <T>
168    * the class that the mock object should extend.
169    * @param toMock
170    * the class that the mock object should extend.
171    * @param mockedMethods
172    * methods that will be mocked, other methods will behave
173    * normally
174    * @return the mock object.
175    *
176    * @deprecated Use {@link #createMockBuilder(Class)} instead
177    */
 
178  12 toggle @Deprecated
179    public static <T> T createStrictMock(final Class<T> toMock, final Method... mockedMethods) {
180  12 return createStrictControl().createMock(toMock, mockedMethods);
181    }
182   
183    /**
184    * Creates a mock object that extends the given class, order checking is
185    * enabled by default.
186    *
187    * @param <T>
188    * the class that the mock object should extend.
189    * @param name
190    * the name of the mock object.
191    * @param toMock
192    * the class that the mock object should extend.
193    * @param mockedMethods
194    * methods that will be mocked, other methods will behave
195    * normally
196    * @return the mock object.
197    *
198    * @deprecated Use {@link #createMockBuilder(Class)} instead
199    */
 
200  7 toggle @Deprecated
201    public static <T> T createStrictMock(final String name, final Class<T> toMock,
202    final Method... mockedMethods) {
203  7 return createStrictControl().createMock(name, toMock, mockedMethods);
204    }
205   
206    /**
207    * Creates a mock object that extends the given class, order checking is
208    * enabled by default.
209    *
210    * @param <T>
211    * the class that the mock object should extend.
212    * @param toMock
213    * the class that the mock object should extend.
214    * @param constructorArgs
215    * constructor and parameters used to instantiate the mock.
216    * @param mockedMethods
217    * methods that will be mocked, other methods will behave
218    * normally
219    * @return the mock object.
220    *
221    * @deprecated Use {@link #createMockBuilder(Class)} instead
222    */
 
223  6 toggle @Deprecated
224    public static <T> T createStrictMock(final Class<T> toMock, final ConstructorArgs constructorArgs,
225    final Method... mockedMethods) {
226  6 return createStrictControl().createMock(toMock, constructorArgs, mockedMethods);
227    }
228   
229    /**
230    * Creates a mock object that extends the given class, order checking is
231    * enabled by default.
232    *
233    * @param <T>
234    * the class that the mock object should extend.
235    * @param name
236    * the name of the mock object.
237    * @param toMock
238    * the class that the mock object should extend.
239    * @param constructorArgs
240    * constructor and parameters used to instantiate the mock.
241    * @param mockedMethods
242    * methods that will be mocked, other methods will behave
243    * normally
244    * @return the mock object.
245    *
246    * @deprecated Use {@link #createMockBuilder(Class)} instead
247    */
 
248  6 toggle @Deprecated
249    public static <T> T createStrictMock(final String name, final Class<T> toMock,
250    final ConstructorArgs constructorArgs, final Method... mockedMethods) {
251  6 return createStrictControl().createMock(name, toMock, constructorArgs, mockedMethods);
252    }
253   
254    /**
255    * Creates a mock object that extends the given class, order checking is
256    * disabled by default.
257    *
258    * @param <T>
259    * the class that the mock object should extend.
260    * @param toMock
261    * the class that the mock object should extend.
262    * @param mockedMethods
263    * methods that will be mocked, other methods will behave
264    * normally
265    * @return the mock object.
266    *
267    * @deprecated Use {@link #createMockBuilder(Class)} instead
268    */
 
269  12 toggle @Deprecated
270    public static <T> T createMock(final Class<T> toMock, final Method... mockedMethods) {
271  12 return createControl().createMock(toMock, mockedMethods);
272    }
273   
274    /**
275    * Creates a mock object that extends the given class, order checking is
276    * disabled by default.
277    *
278    * @param <T>
279    * the class that the mock object should extend.
280    * @param name
281    * the name of the mock object.
282    * @param toMock
283    * the class that the mock object should extend.
284    * @param mockedMethods
285    * methods that will be mocked, other methods will behave
286    * normally
287    * @return the mock object.
288    *
289    * @deprecated Use {@link #createMockBuilder(Class)} instead
290    */
 
291  7 toggle @Deprecated
292    public static <T> T createMock(final String name, final Class<T> toMock, final Method... mockedMethods) {
293  7 return createControl().createMock(name, toMock, mockedMethods);
294    }
295   
296    /**
297    * Creates a mock object that extends the given class, order checking is
298    * disabled by default.
299    *
300    * @param <T>
301    * the class that the mock object should extend.
302    * @param toMock
303    * the class that the mock object should extend.
304    * @param constructorArgs
305    * constructor and parameters used to instantiate the mock.
306    * @param mockedMethods
307    * methods that will be mocked, other methods will behave
308    * normally
309    * @return the mock object.
310    *
311    * @deprecated Use {@link #createMockBuilder(Class)} instead
312    */
 
313  9 toggle @Deprecated
314    public static <T> T createMock(final Class<T> toMock, final ConstructorArgs constructorArgs,
315    final Method... mockedMethods) {
316  9 return createControl().createMock(toMock, constructorArgs, mockedMethods);
317    }
318   
319    /**
320    * Creates a mock object that extends the given class, order checking is
321    * disabled by default.
322    *
323    * @param <T>
324    * the class that the mock object should extend.
325    * @param name
326    * the name of the mock object.
327    * @param toMock
328    * the class that the mock object should extend.
329    * @param constructorArgs
330    * constructor and parameters used to instantiate the mock.
331    * @param mockedMethods
332    * methods that will be mocked, other methods will behave
333    * normally
334    * @return the mock object.
335    *
336    * @deprecated Use {@link #createMockBuilder(Class)} instead
337    */
 
338  6 toggle @Deprecated
339    public static <T> T createMock(final String name, final Class<T> toMock,
340    final ConstructorArgs constructorArgs, final Method... mockedMethods) {
341  6 return createControl().createMock(name, toMock, constructorArgs, mockedMethods);
342    }
343   
344    /**
345    * Creates a mock object that extends the given class, order checking is
346    * disabled by default, and the mock object will return <code>0</code>,
347    * <code>null</code> or <code>false</code> for unexpected invocations.
348    *
349    * @param <T>
350    * the class that the mock object should extend.
351    * @param toMock
352    * the class that the mock object should extend.
353    * @param mockedMethods
354    * methods that will be mocked, other methods will behave
355    * normally
356    * @return the mock object.
357    *
358    * @deprecated Use {@link #createMockBuilder(Class)} instead
359    */
 
360  12 toggle @Deprecated
361    public static <T> T createNiceMock(final Class<T> toMock, final Method... mockedMethods) {
362  12 return createNiceControl().createMock(toMock, mockedMethods);
363    }
364   
365    /**
366    * Creates a mock object that extends the given class, order checking is
367    * disabled by default, and the mock object will return <code>0</code>,
368    * <code>null</code> or <code>false</code> for unexpected invocations.
369    *
370    * @param <T>
371    * the class that the mock object should extend.
372    * @param name
373    * the name of the mock object.
374    * @param toMock
375    * the class that the mock object should extend.
376    * @param mockedMethods
377    * methods that will be mocked, other methods will behave
378    * normally
379    * @return the mock object.
380    *
381    * @deprecated Use {@link #createMockBuilder(Class)} instead
382    */
 
383  7 toggle @Deprecated
384    public static <T> T createNiceMock(final String name, final Class<T> toMock,
385    final Method... mockedMethods) {
386  7 return createNiceControl().createMock(name, toMock, mockedMethods);
387    }
388   
389    /**
390    * Creates a mock object that extends the given class, order checking is
391    * disabled by default, and the mock object will return <code>0</code>,
392    * <code>null</code> or <code>false</code> for unexpected invocations.
393    *
394    * @param <T>
395    * the class that the mock object should extend.
396    * @param toMock
397    * the class that the mock object should extend.
398    * @param constructorArgs
399    * constructor and parameters used to instantiate the mock.
400    * @param mockedMethods
401    * methods that will be mocked, other methods will behave
402    * normally
403    * @return the mock object.
404    *
405    * @deprecated Use {@link #createMockBuilder(Class)} instead
406    */
 
407  6 toggle @Deprecated
408    public static <T> T createNiceMock(final Class<T> toMock, final ConstructorArgs constructorArgs,
409    final Method... mockedMethods) {
410  6 return createNiceControl().createMock(toMock, constructorArgs, mockedMethods);
411    }
412   
413    /**
414    * Creates a mock object that extends the given class, order checking is
415    * disabled by default, and the mock object will return <code>0</code>,
416    * <code>null</code> or <code>false</code> for unexpected invocations.
417    *
418    * @param <T>
419    * the class that the mock object should extend.
420    * @param name
421    * the name of the mock object.
422    * @param toMock
423    * the class that the mock object should extend.
424    * @param constructorArgs
425    * constructor and parameters used to instantiate the mock.
426    * @param mockedMethods
427    * methods that will be mocked, other methods will behave
428    * normally
429    * @return the mock object.
430    *
431    * @deprecated Use {@link #createMockBuilder(Class)} instead
432    */
 
433  6 toggle @Deprecated
434    public static <T> T createNiceMock(final String name, final Class<T> toMock,
435    final ConstructorArgs constructorArgs, final Method... mockedMethods) {
436  6 return createNiceControl().createMock(name, toMock, constructorArgs, mockedMethods);
437    }
438   
439    /**
440    * Create a mock builder allowing to create a partial mock for the given
441    * class or interface.
442    *
443    * @param <T>
444    * the interface that the mock object should implement.
445    * @param toMock
446    * the class of the interface that the mock object should
447    * implement.
448    * @return a mock builder to create a partial mock
449    */
 
450  75 toggle public static <T> IMockBuilder<T> createMockBuilder(final Class<T> toMock) {
451  75 return new MockBuilder<T>(toMock);
452    }
453   
454    /**
455    * Creates a control, order checking is enabled by default.
456    *
457    * @return the control.
458    */
 
459  390 toggle public static IMocksControl createStrictControl() {
460  390 return new MocksControl(MocksControl.MockType.STRICT);
461    }
462   
463    /**
464    * Creates a control, order checking is disabled by default.
465    *
466    * @return the control.
467    */
 
468  1997 toggle public static IMocksControl createControl() {
469  1997 return new MocksControl(MocksControl.MockType.DEFAULT);
470    }
471   
472    /**
473    * Creates a control, order checking is disabled by default, and the mock
474    * objects created by this control will return <code>0</code>,
475    * <code>null</code> or <code>false</code> for unexpected invocations.
476    *
477    * @return the control.
478    */
 
479  269 toggle public static IMocksControl createNiceControl() {
480  269 return new MocksControl(MocksControl.MockType.NICE);
481    }
482   
483    /**
484    * Returns the expectation setter for the last expected invocation in the
485    * current thread.
486    *
487    * @param <T>
488    * type returned by the expected method
489    * @param value
490    * the parameter is used to transport the type to the
491    * ExpectationSetter. It allows writing the expected call as
492    * argument, i.e.
493    * <code>expect(mock.getName()).andReturn("John Doe")<code>.
494    *
495    * @return the expectation setter.
496    */
 
497  2566 toggle public static <T> IExpectationSetters<T> expect(final T value) {
498  2566 return EasyMock.getControlForLastCall();
499    }
500   
501    /**
502    * Returns the expectation setter for the last expected invocation in the
503    * current thread. This method is used for expected invocations on void
504    * methods.
505    *
506    * @param <T>
507    * type returned by the expected method
508    * @return the expectation setter.
509    */
 
510  220 toggle public static <T> IExpectationSetters<T> expectLastCall() {
511  220 return getControlForLastCall();
512    }
513   
 
514  2786 toggle @SuppressWarnings("unchecked")
515    private static <T> IExpectationSetters<T> getControlForLastCall() {
516  2786 final MocksControl lastControl = LastControl.lastControl();
517  2786 if (lastControl == null) {
518  20 LastControl.pullMatchers(); // cleanup matchers to prevent impacting
519    // other tests
520  20 throw new IllegalStateException("no last call on a mock available");
521    }
522  2766 return (IExpectationSetters<T>) lastControl;
523    }
524   
525    /**
526    * Expects any boolean argument. For details, see the EasyMock
527    * documentation.
528    *
529    * @return <code>false</code>.
530    */
 
531  10 toggle public static boolean anyBoolean() {
532  10 reportMatcher(Any.ANY);
533  10 return false;
534    }
535   
536    /**
537    * Expects any byte argument. For details, see the EasyMock documentation.
538    *
539    * @return <code>0</code>.
540    */
 
541  10 toggle public static byte anyByte() {
542  10 reportMatcher(Any.ANY);
543  10 return 0;
544    }
545   
546    /**
547    * Expects any char argument. For details, see the EasyMock documentation.
548    *
549    * @return <code>0</code>.
550    */
 
551  10 toggle public static char anyChar() {
552  10 reportMatcher(Any.ANY);
553  10 return 0;
554    }
555   
556    /**
557    * Expects any int argument. For details, see the EasyMock documentation.
558    *
559    * @return <code>0</code>.
560    */
 
561  120 toggle public static int anyInt() {
562  120 reportMatcher(Any.ANY);
563  120 return 0;
564    }
565   
566    /**
567    * Expects any long argument. For details, see the EasyMock documentation.
568    *
569    * @return <code>0</code>.
570    */
 
571  10 toggle public static long anyLong() {
572  10 reportMatcher(Any.ANY);
573  10 return 0;
574    }
575   
576    /**
577    * Expects any float argument. For details, see the EasyMock documentation.
578    *
579    * @return <code>0</code>.
580    */
 
581  10 toggle public static float anyFloat() {
582  10 reportMatcher(Any.ANY);
583  10 return 0;
584    }
585   
586    /**
587    * Expects any double argument. For details, see the EasyMock documentation.
588    *
589    * @return <code>0</code>.
590    */
 
591  10 toggle public static double anyDouble() {
592  10 reportMatcher(Any.ANY);
593  10 return 0;
594    }
595   
596    /**
597    * Expects any short argument. For details, see the EasyMock documentation.
598    *
599    * @return <code>0</code>.
600    */
 
601  10 toggle public static short anyShort() {
602  10 reportMatcher(Any.ANY);
603  10 return 0;
604    }
605   
606    /**
607    * Expects any Object argument. For details, see the EasyMock documentation.
608    * This matcher (and {@link #anyObject(Class)}) can be used in these three
609    * ways:
610    * <ul>
611    * <li><code>(T)EasyMock.anyObject() // explicit cast</code></li>
612    * <li>
613    * <code>EasyMock.&lt;T&gt; anyObject() // fixing the returned generic</code>
614    * </li>
615    * <li>
616    * <code>EasyMock.anyObject(T.class) // pass the returned type in parameter</code>
617    * </li>
618    * </ul>
619    *
620    * @param <T>
621    * type of the method argument to match
622    * @return <code>null</code>.
623    */
 
624  40 toggle public static <T> T anyObject() {
625  40 reportMatcher(Any.ANY);
626  40 return null;
627    }
628   
629    /**
630    * Expects any Object argument. For details, see the EasyMock documentation.
631    * To work well with generics, this matcher can be used in three different
632    * ways. See {@link #anyObject()}.
633    *
634    * @param <T>
635    * type of the method argument to match
636    * @param clazz
637    * the class of the argument to match
638    * @return <code>null</code>.
639    */
 
640  5 toggle public static <T> T anyObject(final Class<T> clazz) {
641  5 reportMatcher(Any.ANY);
642  5 return null;
643    }
644   
645    /**
646    * Expects a comparable argument greater than or equal the given value. For
647    * details, see the EasyMock documentation.
648    *
649    * @param <T>
650    * type of the method argument to match
651    * @param value
652    * the given value.
653    * @return <code>null</code>.
654    */
 
655  5 toggle public static <T extends Comparable<T>> T geq(final Comparable<T> value) {
656  5 reportMatcher(new GreaterOrEqual<T>(value));
657  5 return null;
658    }
659   
660    /**
661    * Expects a byte argument greater than or equal to the given value. For
662    * details, see the EasyMock documentation.
663    *
664    * @param value
665    * the given value.
666    * @return <code>0</code>.
667    */
 
668  5 toggle public static byte geq(final byte value) {
669  5 reportMatcher(new GreaterOrEqual<Byte>(value));
670  5 return 0;
671    }
672   
673    /**
674    * Expects a double argument greater than or equal to the given value. For
675    * details, see the EasyMock documentation.
676    *
677    * @param value
678    * the given value.
679    * @return <code>0</code>.
680    */
 
681  5 toggle public static double geq(final double value) {
682  5 reportMatcher(new GreaterOrEqual<Double>(value));
683  5 return 0;
684    }
685   
686    /**
687    * Expects a float argument greater than or equal to the given value. For
688    * details, see the EasyMock documentation.
689    *
690    * @param value
691    * the given value.
692    * @return <code>0</code>.
693    */
 
694  5 toggle public static float geq(final float value) {
695  5 reportMatcher(new GreaterOrEqual<Float>(value));
696  5 return 0;
697    }
698   
699    /**
700    * Expects an int argument greater than or equal to the given value. For
701    * details, see the EasyMock documentation.
702    *
703    * @param value
704    * the given value.
705    * @return <code>0</code>.
706    */
 
707  20 toggle public static int geq(final int value) {
708  20 reportMatcher(new GreaterOrEqual<Integer>(value));
709  20 return 0;
710    }
711   
712    /**
713    * Expects a long argument greater than or equal to the given value. For
714    * details, see the EasyMock documentation.
715    *
716    * @param value
717    * the given value.
718    * @return <code>0</code>.
719    */
 
720  5 toggle public static long geq(final long value) {
721  5 reportMatcher(new GreaterOrEqual<Long>(value));
722  5 return 0;
723    }
724   
725    /**
726    * Expects a short argument greater than or equal to the given value. For
727    * details, see the EasyMock documentation.
728    *
729    * @param value
730    * the given value.
731    * @return <code>0</code>.
732    */
 
733  5 toggle public static short geq(final short value) {
734  5 reportMatcher(new GreaterOrEqual<Short>(value));
735  5 return 0;
736    }
737   
738    /**
739    * Expects a comparable argument less than or equal the given value. For
740    * details, see the EasyMock documentation.
741    *
742    * @param <T>
743    * type of the method argument to match
744    * @param value
745    * the given value.
746    * @return <code>null</code>.
747    */
 
748  5 toggle public static <T extends Comparable<T>> T leq(final Comparable<T> value) {
749  5 reportMatcher(new LessOrEqual<T>(value));
750  5 return null;
751    }
752   
753    /**
754    * Expects a byte argument less than or equal to the given value. For
755    * details, see the EasyMock documentation.
756    *
757    * @param value
758    * the given value.
759    * @return <code>0</code>.
760    */
 
761  5 toggle public static byte leq(final byte value) {
762  5 reportMatcher(new LessOrEqual<Byte>(value));
763  5 return 0;
764    }
765   
766    /**
767    * Expects a double argument less than or equal to the given value. For
768    * details, see the EasyMock documentation.
769    *
770    * @param value
771    * the given value.
772    * @return <code>0</code>.
773    */
 
774  5 toggle public static double leq(final double value) {
775  5 reportMatcher(new LessOrEqual<Double>(value));
776  5 return 0;
777    }
778   
779    /**
780    * Expects a float argument less than or equal to the given value. For
781    * details, see the EasyMock documentation.
782    *
783    * @param value
784    * the given value.
785    * @return <code>0</code>.
786    */
 
787  5 toggle public static float leq(final float value) {
788  5 reportMatcher(new LessOrEqual<Float>(value));
789  5 return 0;
790    }
791   
792    /**
793    * Expects an int argument less than or equal to the given value. For
794    * details, see the EasyMock documentation.
795    *
796    * @param value
797    * the given value.
798    * @return <code>0</code>.
799    */
 
800  20 toggle public static int leq(final int value) {
801  20 reportMatcher(new LessOrEqual<Integer>(value));
802  20 return 0;
803    }
804   
805    /**
806    * Expects a long argument less than or equal to the given value. For
807    * details, see the EasyMock documentation.
808    *
809    * @param value
810    * the given value.
811    * @return <code>0</code>.
812    */
 
813  5 toggle public static long leq(final long value) {
814  5 reportMatcher(new LessOrEqual<Long>(value));
815  5 return 0;
816    }
817   
818    /**
819    * Expects a short argument less than or equal to the given value. For
820    * details, see the EasyMock documentation.
821    *
822    * @param value
823    * the given value.
824    * @return <code>0</code>.
825    */
 
826  5 toggle public static short leq(final short value) {
827  5 reportMatcher(new LessOrEqual<Short>(value));
828  5 return 0;
829    }
830   
831    /**
832    * Expects a comparable argument greater than the given value. For details,
833    * see the EasyMock documentation.
834    *
835    * @param <T>
836    * type of the method argument to match
837    * @param value
838    * the given value.
839    * @return <code>null</code>.
840    */
 
841  5 toggle public static <T extends Comparable<T>> T gt(final Comparable<T> value) {
842  5 reportMatcher(new GreaterThan<T>(value));
843  5 return null;
844    }
845   
846    /**
847    * Expects a byte argument greater than the given value. For details, see
848    * the EasyMock documentation.
849    *
850    * @param value
851    * the given value.
852    * @return <code>0</code>.
853    */
 
854  5 toggle public static byte gt(final byte value) {
855  5 reportMatcher(new GreaterThan<Byte>(value));
856  5 return 0;
857    }
858   
859    /**
860    * Expects a double argument greater than the given value. For details, see
861    * the EasyMock documentation.
862    *
863    * @param value
864    * the given value.
865    * @return <code>0</code>.
866    */
 
867  5 toggle public static double gt(final double value) {
868  5 reportMatcher(new GreaterThan<Double>(value));
869  5 return 0;
870    }
871   
872    /**
873    * Expects a float argument greater than the given value. For details, see
874    * the EasyMock documentation.
875    *
876    * @param value
877    * the given value.
878    * @return <code>0</code>.
879    */
 
880  5 toggle public static float gt(final float value) {
881  5 reportMatcher(new GreaterThan<Float>(value));
882  5 return 0;
883    }
884   
885    /**
886    * Expects an int argument greater than the given value. For details, see
887    * the EasyMock documentation.
888    *
889    * @param value
890    * the given value.
891    * @return <code>0</code>.
892    */
 
893  15 toggle public static int gt(final int value) {
894  15 reportMatcher(new GreaterThan<Integer>(value));
895  15 return 0;
896    }
897   
898    /**
899    * Expects a long argument greater than the given value. For details, see
900    * the EasyMock documentation.
901    *
902    * @param value
903    * the given value.
904    * @return <code>0</code>.
905    */
 
906  5 toggle public static long gt(final long value) {
907  5 reportMatcher(new GreaterThan<Long>(value));
908  5 return 0;
909    }
910   
911    /**
912    * Expects a short argument greater than the given value. For details, see
913    * the EasyMock documentation.
914    *
915    * @param value
916    * the given value.
917    * @return <code>0</code>.
918    */
 
919  5 toggle public static short gt(final short value) {
920  5 reportMatcher(new GreaterThan<Short>(value));
921  5 return 0;
922    }
923   
924    /**
925    * Expects a comparable argument less than the given value. For details, see
926    * the EasyMock documentation.
927    *
928    * @param <T>
929    * type of the method argument to match
930    * @param value
931    * the given value.
932    * @return <code>null</code>.
933    */
 
934  5 toggle public static <T extends Comparable<T>> T lt(final Comparable<T> value) {
935  5 reportMatcher(new LessThan<T>(value));
936  5 return null;
937    }
938   
939    /**
940    * Expects a byte argument less than the given value. For details, see the
941    * EasyMock documentation.
942    *
943    * @param value
944    * the given value.
945    * @return <code>0</code>.
946    */
 
947  5 toggle public static byte lt(final byte value) {
948  5 reportMatcher(new LessThan<Byte>(value));
949  5 return 0;
950    }
951   
952    /**
953    * Expects a double argument less than the given value. For details, see the
954    * EasyMock documentation.
955    *
956    * @param value
957    * the given value.
958    * @return <code>0</code>.
959    */
 
960  5 toggle public static double lt(final double value) {
961  5 reportMatcher(new LessThan<Double>(value));
962  5 return 0;
963    }
964   
965    /**
966    * Expects a float argument less than the given value. For details, see the
967    * EasyMock documentation.
968    *
969    * @param value
970    * the given value.
971    * @return <code>0</code>.
972    */
 
973  5 toggle public static float lt(final float value) {
974  5 reportMatcher(new LessThan<Float>(value));
975  5 return 0;
976    }
977   
978    /**
979    * Expects an int argument less than the given value. For details, see the
980    * EasyMock documentation.
981    *
982    * @param value
983    * the given value.
984    * @return <code>0</code>.
985    */
 
986  20 toggle public static int lt(final int value) {
987  20 reportMatcher(new LessThan<Integer>(value));
988  20 return 0;
989    }
990   
991    /**
992    * Expects a long argument less than the given value. For details, see the
993    * EasyMock documentation.
994    *
995    * @param value
996    * the given value.
997    * @return <code>0</code>.
998    */
 
999  5 toggle public static long lt(final long value) {
1000  5 reportMatcher(new LessThan<Long>(value));
1001  5 return 0;
1002    }
1003   
1004    /**
1005    * Expects a short argument less than the given value. For details, see the
1006    * EasyMock documentation.
1007    *
1008    * @param value
1009    * the given value.
1010    * @return <code>0</code>.
1011    */
 
1012  5 toggle public static short lt(final short value) {
1013  5 reportMatcher(new LessThan<Short>(value));
1014  5 return 0;
1015    }
1016   
1017    /**
1018    * Expects an object implementing the given class. For details, see the
1019    * EasyMock documentation.
1020    *
1021    * @param <T>
1022    * the accepted type.
1023    * @param clazz
1024    * the class of the accepted type.
1025    * @return <code>null</code>.
1026    */
 
1027  35 toggle public static <T> T isA(final Class<T> clazz) {
1028  35 reportMatcher(new InstanceOf(clazz));
1029  35 return null;
1030    }
1031   
1032    /**
1033    * Expects a string that contains the given substring. For details, see the
1034    * EasyMock documentation.
1035    *
1036    * @param substring
1037    * the substring.
1038    * @return <code>null</code>.
1039    */
 
1040  30 toggle public static String contains(final String substring) {
1041  30 reportMatcher(new Contains(substring));
1042  30 return null;
1043    }
1044   
1045    /**
1046    * Expects a boolean that matches both given expectations.
1047    *
1048    * @param first
1049    * placeholder for the first expectation.
1050    * @param second
1051    * placeholder for the second expectation.
1052    * @return <code>false</code>.
1053    */
 
1054  5 toggle public static boolean and(final boolean first, final boolean second) {
1055  5 LastControl.reportAnd(2);
1056  5 return false;
1057    }
1058   
1059    /**
1060    * Expects a byte that matches both given expectations.
1061    *
1062    * @param first
1063    * placeholder for the first expectation.
1064    * @param second
1065    * placeholder for the second expectation.
1066    * @return <code>0</code>.
1067    */
 
1068  5 toggle public static byte and(final byte first, final byte second) {
1069  5 LastControl.reportAnd(2);
1070  5 return 0;
1071    }
1072   
1073    /**
1074    * Expects a char that matches both given expectations.
1075    *
1076    * @param first
1077    * placeholder for the first expectation.
1078    * @param second
1079    * placeholder for the second expectation.
1080    * @return <code>0</code>.
1081    */
 
1082  5 toggle public static char and(final char first, final char second) {
1083  5 LastControl.reportAnd(2);
1084  5 return 0;
1085    }
1086   
1087    /**
1088    * Expects a double that matches both given expectations.
1089    *
1090    * @param first
1091    * placeholder for the first expectation.
1092    * @param second
1093    * placeholder for the second expectation.
1094    * @return <code>0</code>.
1095    */
 
1096  5 toggle public static double and(final double first, final double second) {
1097  5 LastControl.reportAnd(2);
1098  5 return 0;
1099    }
1100   
1101    /**
1102    * Expects a float that matches both given expectations.
1103    *
1104    * @param first
1105    * placeholder for the first expectation.
1106    * @param second
1107    * placeholder for the second expectation.
1108    * @return <code>0</code>.
1109    */
 
1110  5 toggle public static float and(final float first, final float second) {
1111  5 LastControl.reportAnd(2);
1112  5 return 0;
1113    }
1114   
1115    /**
1116    * Expects an int that matches both given expectations.
1117    *
1118    * @param first
1119    * placeholder for the first expectation.
1120    * @param second
1121    * placeholder for the second expectation.
1122    * @return <code>0</code>.
1123    */
 
1124  10 toggle public static int and(final int first, final int second) {
1125  10 LastControl.reportAnd(2);
1126  10 return 0;
1127    }
1128   
1129    /**
1130    * Expects a long that matches both given expectations.
1131    *
1132    * @param first
1133    * placeholder for the first expectation.
1134    * @param second
1135    * placeholder for the second expectation.
1136    * @return <code>0</code>.
1137    */
 
1138  5 toggle public static long and(final long first, final long second) {
1139  5 LastControl.reportAnd(2);
1140  5 return 0;
1141    }
1142   
1143    /**
1144    * Expects a short that matches both given expectations.
1145    *
1146    * @param first
1147    * placeholder for the first expectation.
1148    * @param second
1149    * placeholder for the second expectation.
1150    * @return <code>0</code>.
1151    */
 
1152  5 toggle public static short and(final short first, final short second) {
1153  5 LastControl.reportAnd(2);
1154  5 return 0;
1155    }
1156   
1157    /**
1158    * Expects an Object that matches both given expectations.
1159    *
1160    * @param <T>
1161    * the type of the object, it is passed through to prevent casts.
1162    * @param first
1163    * placeholder for the first expectation.
1164    * @param second
1165    * placeholder for the second expectation.
1166    * @return <code>null</code>.
1167    */
 
1168  40 toggle public static <T> T and(final T first, final T second) {
1169  40 LastControl.reportAnd(2);
1170  40 return null;
1171    }
1172   
1173    /**
1174    * Expects a boolean that matches one of the given expectations.
1175    *
1176    * @param first
1177    * placeholder for the first expectation.
1178    * @param second
1179    * placeholder for the second expectation.
1180    * @return <code>false</code>.
1181    */
 
1182  5 toggle public static boolean or(final boolean first, final boolean second) {
1183  5 LastControl.reportOr(2);
1184  5 return false;
1185    }
1186   
1187    /**
1188    * Expects a byte that matches one of the given expectations.
1189    *
1190    * @param first
1191    * placeholder for the first expectation.
1192    * @param second
1193    * placeholder for the second expectation.
1194    * @return <code>0</code>.
1195    */
 
1196  5 toggle public static byte or(final byte first, final byte second) {
1197  5 LastControl.reportOr(2);
1198  5 return 0;
1199    }
1200   
1201    /**
1202    * Expects a char that matches one of the given expectations.
1203    *
1204    * @param first
1205    * placeholder for the first expectation.
1206    * @param second
1207    * placeholder for the second expectation.
1208    * @return <code>0</code>.
1209    */
 
1210  5 toggle public static char or(final char first, final char second) {
1211  5 LastControl.reportOr(2);
1212  5 return 0;
1213    }
1214   
1215    /**
1216    * Expects a double that matches one of the given expectations.
1217    *
1218    * @param first
1219    * placeholder for the first expectation.
1220    * @param second
1221    * placeholder for the second expectation.
1222    * @return <code>0</code>.
1223    */
 
1224  5 toggle public static double or(final double first, final double second) {
1225  5 LastControl.reportOr(2);
1226  5 return 0;
1227    }
1228   
1229    /**
1230    * Expects a float that matches one of the given expectations.
1231    *
1232    * @param first
1233    * placeholder for the first expectation.
1234    * @param second
1235    * placeholder for the second expectation.
1236    * @return <code>0</code>.
1237    */
 
1238  5 toggle public static float or(final float first, final float second) {
1239  5 LastControl.reportOr(2);
1240  5 return 0;
1241    }
1242   
1243    /**
1244    * Expects an int that matches one of the given expectations.
1245    *
1246    * @param first
1247    * placeholder for the first expectation.
1248    * @param second
1249    * placeholder for the second expectation.
1250    * @return <code>0</code>.
1251    */
 
1252  10 toggle public static int or(final int first, final int second) {
1253  10 LastControl.reportOr(2);
1254  10 return first;
1255    }
1256   
1257    /**
1258    * Expects a long that matches one of the given expectations.
1259    *
1260    * @param first
1261    * placeholder for the first expectation.
1262    * @param second
1263    * placeholder for the second expectation.
1264    * @return <code>0</code>.
1265    */
 
1266  5 toggle public static long or(final long first, final long second) {
1267  5 LastControl.reportOr(2);
1268  5 return 0;
1269    }
1270   
1271    /**
1272    * Expects a short that matches one of the given expectations.
1273    *
1274    * @param first
1275    * placeholder for the first expectation.
1276    * @param second
1277    * placeholder for the second expectation.
1278    * @return <code>0</code>.
1279    */
 
1280  5 toggle public static short or(final short first, final short second) {
1281  5 LastControl.reportOr(2);
1282  5 return 0;
1283    }
1284   
1285    /**
1286    * Expects an Object that matches one of the given expectations.
1287    *
1288    * @param <T>
1289    * the type of the object, it is passed through to prevent casts.
1290    * @param first
1291    * placeholder for the first expectation.
1292    * @param second
1293    * placeholder for the second expectation.
1294    * @return <code>null</code>.
1295    */
 
1296  15 toggle public static <T> T or(final T first, final T second) {
1297  15 LastControl.reportOr(2);
1298  10 return null;
1299    }
1300   
1301    /**
1302    * Expects a boolean that does not match the given expectation.
1303    *
1304    * @param first
1305    * placeholder for the expectation.
1306    * @return <code>false</code>.
1307    */
 
1308  5 toggle public static boolean not(final boolean first) {
1309  5 LastControl.reportNot();
1310  5 return false;
1311    }
1312   
1313    /**
1314    * Expects a byte that does not match the given expectation.
1315    *
1316    * @param first
1317    * placeholder for the expectation.
1318    * @return <code>0</code>.
1319    */
 
1320  5 toggle public static byte not(final byte first) {
1321  5 LastControl.reportNot();
1322  5 return 0;
1323    }
1324   
1325    /**
1326    * Expects a char that does not match the given expectation.
1327    *
1328    * @param first
1329    * placeholder for the expectation.
1330    * @return <code>0</code>.
1331    */
 
1332  5 toggle public static char not(final char first) {
1333  5 LastControl.reportNot();
1334  5 return 0;
1335    }
1336   
1337    /**
1338    * Expects a double that does not match the given expectation.
1339    *
1340    * @param first
1341    * placeholder for the expectation.
1342    * @return <code>0</code>.
1343    */
 
1344  5 toggle public static double not(final double first) {
1345  5 LastControl.reportNot();
1346  5 return 0;
1347    }
1348   
1349    /**
1350    * Expects a float that does not match the given expectation.
1351    *
1352    * @param first
1353    * placeholder for the expectation.
1354    * @return <code>0</code>.
1355    */
 
1356  5 toggle public static float not(final float first) {
1357  5 LastControl.reportNot();
1358  5 return first;
1359    }
1360   
1361    /**
1362    * Expects an int that does not match the given expectation.
1363    *
1364    * @param first
1365    * placeholder for the expectation.
1366    * @return <code>0</code>.
1367    */
 
1368  5 toggle public static int not(final int first) {
1369  5 LastControl.reportNot();
1370  5 return 0;
1371    }
1372   
1373    /**
1374    * Expects a long that does not match the given expectation.
1375    *
1376    * @param first
1377    * placeholder for the expectation.
1378    * @return <code>0</code>.
1379    */
 
1380  5 toggle public static long not(final long first) {
1381  5 LastControl.reportNot();
1382  5 return 0;
1383    }
1384   
1385    /**
1386    * Expects a short that does not match the given expectation.
1387    *
1388    * @param first
1389    * placeholder for the expectation.
1390    * @return <code>0</code>.
1391    */
 
1392  5 toggle public static short not(final short first) {
1393  5 LastControl.reportNot();
1394  5 return 0;
1395    }
1396   
1397    /**
1398    * Expects an Object that does not match the given expectation.
1399    *
1400    * @param <T>
1401    * the type of the object, it is passed through to prevent casts.
1402    * @param first
1403    * placeholder for the expectation.
1404    * @return <code>null</code>.
1405    */
 
1406  30 toggle public static <T> T not(final T first) {
1407  30 LastControl.reportNot();
1408  25 return null;
1409    }
1410   
1411    /**
1412    * Expects a boolean that is equal to the given value.
1413    *
1414    * @param value
1415    * the given value.
1416    * @return <code>0</code>.
1417    */
 
1418  25 toggle public static boolean eq(final boolean value) {
1419  25 reportMatcher(new Equals(value));
1420  25 return false;
1421    }
1422   
1423    /**
1424    * Expects a byte that is equal to the given value.
1425    *
1426    * @param value
1427    * the given value.
1428    * @return <code>0</code>.
1429    */
 
1430  25 toggle public static byte eq(final byte value) {
1431  25 reportMatcher(new Equals(value));
1432  25 return 0;
1433    }
1434   
1435    /**
1436    * Expects a char that is equal to the given value.
1437    *
1438    * @param value
1439    * the given value.
1440    * @return <code>0</code>.
1441    */
 
1442  25 toggle public static char eq(final char value) {
1443  25 reportMatcher(new Equals(value));
1444  25 return 0;
1445    }
1446   
1447    /**
1448    * Expects a double that is equal to the given value.
1449    *
1450    * @param value
1451    * the given value.
1452    * @return <code>0</code>.
1453    */
 
1454  25 toggle public static double eq(final double value) {
1455  25 reportMatcher(new Equals(value));
1456  25 return 0;
1457    }
1458   
1459    /**
1460    * Expects a float that is equal to the given value.
1461    *
1462    * @param value
1463    * the given value.
1464    * @return <code>0</code>.
1465    */
 
1466  25 toggle public static float eq(final float value) {
1467  25 reportMatcher(new Equals(value));
1468  25 return 0;
1469    }
1470   
1471    /**
1472    * Expects an int that is equal to the given value.
1473    *
1474    * @param value
1475    * the given value.
1476    * @return <code>0</code>.
1477    */
 
1478  100 toggle public static int eq(final int value) {
1479  100 reportMatcher(new Equals(value));
1480  100 return 0;
1481    }
1482   
1483    /**
1484    * Expects a long that is equal to the given value.
1485    *
1486    * @param value
1487    * the given value.
1488    * @return <code>0</code>.
1489    */
 
1490  25 toggle public static long eq(final long value) {
1491  25 reportMatcher(new Equals(value));
1492  25 return 0;
1493    }
1494   
1495    /**
1496    * Expects a short that is equal to the given value.
1497    *
1498    * @param value
1499    * the given value.
1500    * @return <code>0</code>.
1501    */
 
1502  25 toggle public static short eq(final short value) {
1503  25 reportMatcher(new Equals(value));
1504  25 return 0;
1505    }
1506   
1507    /**
1508    * Expects an Object that is equal to the given value.
1509    *
1510    * @param <T>
1511    * type of the method argument to match
1512    * @param value
1513    * the given value.
1514    * @return <code>null</code>.
1515    */
 
1516  85 toggle public static <T> T eq(final T value) {
1517  85 reportMatcher(new Equals(value));
1518  85 return null;
1519    }
1520   
1521    /**
1522    * Expects a boolean array that is equal to the given array, i.e. it has to
1523    * have the same length, and each element has to be equal.
1524    *
1525    * @param value
1526    * the given arry.
1527    * @return <code>null</code>.
1528    */
 
1529  5 toggle public static boolean[] aryEq(final boolean[] value) {
1530  5 reportMatcher(new ArrayEquals(value));
1531  5 return null;
1532    }
1533   
1534    /**
1535    * Expects a byte array that is equal to the given array, i.e. it has to
1536    * have the same length, and each element has to be equal.
1537    *
1538    * @param value
1539    * the given arry.
1540    * @return <code>null</code>.
1541    */
 
1542  5 toggle public static byte[] aryEq(final byte[] value) {
1543  5 reportMatcher(new ArrayEquals(value));
1544  5 return null;
1545    }
1546   
1547    /**
1548    * Expects a char array that is equal to the given array, i.e. it has to
1549    * have the same length, and each element has to be equal.
1550    *
1551    * @param value
1552    * the given arry.
1553    * @return <code>null</code>.
1554    */
 
1555  5 toggle public static char[] aryEq(final char[] value) {
1556  5 reportMatcher(new ArrayEquals(value));
1557  5 return null;
1558    }
1559   
1560    /**
1561    * Expects a double array that is equal to the given array, i.e. it has to
1562    * have the same length, and each element has to be equal.
1563    *
1564    * @param value
1565    * the given arry.
1566    * @return <code>null</code>.
1567    */
 
1568  5 toggle public static double[] aryEq(final double[] value) {
1569  5 reportMatcher(new ArrayEquals(value));
1570  5 return null;
1571    }
1572   
1573    /**
1574    * Expects a float array that is equal to the given array, i.e. it has to
1575    * have the same length, and each element has to be equal.
1576    *
1577    * @param value
1578    * the given arry.
1579    * @return <code>null</code>.
1580    */
 
1581  5 toggle public static float[] aryEq(final float[] value) {
1582  5 reportMatcher(new ArrayEquals(value));
1583  5 return null;
1584    }
1585   
1586    /**
1587    * Expects an int array that is equal to the given array, i.e. it has to
1588    * have the same length, and each element has to be equal.
1589    *
1590    * @param value
1591    * the given arry.
1592    * @return <code>null</code>.
1593    */
 
1594  5 toggle public static int[] aryEq(final int[] value) {
1595  5 reportMatcher(new ArrayEquals(value));
1596  5 return null;
1597    }
1598   
1599    /**
1600    * Expects a long array that is equal to the given array, i.e. it has to
1601    * have the same length, and each element has to be equal.
1602    *
1603    * @param value
1604    * the given arry.
1605    * @return <code>null</code>.
1606    */
 
1607  5 toggle public static long[] aryEq(final long[] value) {
1608  5 reportMatcher(new ArrayEquals(value));
1609  5 return null;
1610    }
1611   
1612    /**
1613    * Expects a short array that is equal to the given array, i.e. it has to
1614    * have the same length, and each element has to be equal.
1615    *
1616    * @param value
1617    * the given arry.
1618    * @return <code>null</code>.
1619    */
 
1620  5 toggle public static short[] aryEq(final short[] value) {
1621  5 reportMatcher(new ArrayEquals(value));
1622  5 return null;
1623    }
1624   
1625    /**
1626    * Expects an Object array that is equal to the given array, i.e. it has to
1627    * have the same type, length, and each element has to be equal.
1628    *
1629    * @param <T>
1630    * the type of the array, it is passed through to prevent casts.
1631    * @param value
1632    * the given arry.
1633    * @return <code>null</code>.
1634    */
 
1635  25 toggle public static <T> T[] aryEq(final T[] value) {
1636  25 reportMatcher(new ArrayEquals(value));
1637  25 return null;
1638    }
1639   
1640    /**
1641    * Expects null. To work well with generics, this matcher (and
1642    * {@link #isNull(Class)}) can be used in these three ways:
1643    * <ul>
1644    * <li><code>(T)EasyMock.isNull() // explicit cast</code></li>
1645    * <li>
1646    * <code>EasyMock.&lt;T&gt; isNull() // fixing the returned generic</code></li>
1647    * <li>
1648    * <code>EasyMock.isNull(T.class) // pass the returned type in parameter</code>
1649    * </li>
1650    * </ul>
1651    *
1652    * @param <T>
1653    * type of the method argument to match
1654    * @return <code>null</code>.
1655    */
 
1656  25 toggle public static <T> T isNull() {
1657  25 reportMatcher(Null.NULL);
1658  25 return null;
1659    }
1660   
1661    /**
1662    * Expects null. To work well with generics, this matcher can be used in
1663    * three different ways. See {@link #isNull()}.
1664    *
1665    * @param <T>
1666    * type of the method argument to match
1667    * @param clazz
1668    * the class of the argument to match
1669    * @return <code>null</code>.
1670    *
1671    * @see #isNull()
1672    */
 
1673  5 toggle public static <T> T isNull(final Class<T> clazz) {
1674  5 reportMatcher(Null.NULL);
1675  5 return null;
1676    }
1677   
1678    /**
1679    * Expects not null. To work well with generics, this matcher (and
1680    * {@link #notNull(Class)}) can be used in these three ways:
1681    * <ul>
1682    * <li><code>(T)EasyMock.notNull() // explicit cast</code></li>
1683    * <li>
1684    * <code>EasyMock.&lt;T&gt; notNull() // fixing the returned generic</code></li>
1685    * <li>
1686    * <code>EasyMock.notNull(T.class) // pass the returned type in parameter</code>
1687    * </li>
1688    * </ul>
1689    *
1690    * @param <T>
1691    * type of the method argument to match
1692    * @return <code>null</code>.
1693    */
 
1694  25 toggle public static <T> T notNull() {
1695  25 reportMatcher(NotNull.NOT_NULL);
1696  25 return null;
1697    }
1698   
1699    /**
1700    * Expects not null. To work well with generics, this matcher can be used in
1701    * three different ways. See {@link #notNull()}.
1702    *
1703    * @param <T>
1704    * type of the method argument to match
1705    * @param clazz
1706    * the class of the argument to match
1707    * @return <code>null</code>.
1708    *
1709    * @see #notNull()
1710    */
 
1711  5 toggle public static <T> T notNull(final Class<T> clazz) {
1712  5 reportMatcher(NotNull.NOT_NULL);
1713  5 return null;
1714    }
1715   
1716    /**
1717    * Expects a string that contains a substring that matches the given regular
1718    * expression. For details, see the EasyMock documentation.
1719    *
1720    * @param regex
1721    * the regular expression.
1722    * @return <code>null</code>.
1723    */
 
1724  10 toggle public static String find(final String regex) {
1725  10 reportMatcher(new Find(regex));
1726  10 return null;
1727    }
1728   
1729    /**
1730    * Expects a string that matches the given regular expression. For details,
1731    * see the EasyMock documentation.
1732    *
1733    * @param regex
1734    * the regular expression.
1735    * @return <code>null</code>.
1736    */
 
1737  10 toggle public static String matches(final String regex) {
1738  10 reportMatcher(new Matches(regex));
1739  10 return null;
1740    }
1741   
1742    /**
1743    * Expects a string that starts with the given prefix. For details, see the
1744    * EasyMock documentation.
1745    *
1746    * @param prefix
1747    * the prefix.
1748    * @return <code>null</code>.
1749    */
 
1750  10 toggle public static String startsWith(final String prefix) {
1751  10 reportMatcher(new StartsWith(prefix));
1752  10 return null;
1753    }
1754   
1755    /**
1756    * Expects a string that ends with the given suffix. For details, see the
1757    * EasyMock documentation.
1758    *
1759    * @param suffix
1760    * the suffix.
1761    * @return <code>null</code>.
1762    */
 
1763  10 toggle public static String endsWith(final String suffix) {
1764  10 reportMatcher(new EndsWith(suffix));
1765  10 return null;
1766    }
1767   
1768    /**
1769    * Expects a double that has an absolute difference to the given value that
1770    * is less than the given delta. For details, see the EasyMock
1771    * documentation.
1772    *
1773    * @param value
1774    * the given value.
1775    * @param delta
1776    * the given delta.
1777    * @return <code>0</code>.
1778    */
 
1779  10 toggle public static double eq(final double value, final double delta) {
1780  10 reportMatcher(new EqualsWithDelta(value, delta));
1781  10 return 0;
1782    }
1783   
1784    /**
1785    * Expects a float that has an absolute difference to the given value that
1786    * is less than the given delta. For details, see the EasyMock
1787    * documentation.
1788    *
1789    * @param value
1790    * the given value.
1791    * @param delta
1792    * the given delta.
1793    * @return <code>0</code>.
1794    */
 
1795  15 toggle public static float eq(final float value, final float delta) {
1796  15 reportMatcher(new EqualsWithDelta(value, delta));
1797  15 return 0;
1798    }
1799   
1800    /**
1801    * Expects an Object that is the same as the given value. For details, see
1802    * the EasyMock documentation.
1803    *
1804    * @param <T>
1805    * the type of the object, it is passed through to prevent casts.
1806    * @param value
1807    * the given value.
1808    * @return <code>null</code>.
1809    */
 
1810  10 toggle public static <T> T same(final T value) {
1811  10 reportMatcher(new Same(value));
1812  10 return null;
1813    }
1814   
1815    /**
1816    * Expects a comparable argument equals to the given value according to
1817    * their compareTo method. For details, see the EasMock documentation.
1818    *
1819    * @param <T>
1820    * type of the method argument to match
1821    * @param value
1822    * the given value.
1823    * @return <code>null</code>.
1824    */
 
1825  11 toggle public static <T extends Comparable<T>> T cmpEq(final Comparable<T> value) {
1826  11 reportMatcher(new CompareEqual<T>(value));
1827  11 return null;
1828    }
1829   
1830    /**
1831    * Expects an argument that will be compared using the provided comparator.
1832    * The following comparison will take place:
1833    * <p>
1834    * <code>comparator.compare(actual, expected) operator 0</code>
1835    * </p>
1836    * For details, see the EasyMock documentation.
1837    *
1838    * @param <T>
1839    * type of the method argument to match
1840    * @param value
1841    * the given value.
1842    * @param comparator
1843    * Comparator used to compare the actual with expected value.
1844    * @param operator
1845    * The comparison operator.
1846    * @return <code>null</code>
1847    */
 
1848  35 toggle public static <T> T cmp(final T value, final Comparator<? super T> comparator,
1849    final LogicalOperator operator) {
1850  35 reportMatcher(new Compare<T>(value, comparator, operator));
1851  35 return null;
1852    }
1853   
1854    /**
1855    * Expects a byte that is equal to the given value.
1856    *
1857    * @param value
1858    * the given value.
1859    * @return <code>0</code>.
1860    */
1861   
1862    /**
1863    * Expect any object but captures it for later use.
1864    *
1865    * @param <T>
1866    * Type of the captured object
1867    * @param captured
1868    * Where the parameter is captured
1869    * @return <code>null</code>
1870    */
 
1871  85 toggle public static <T> T capture(final Capture<T> captured) {
1872  85 reportMatcher(new Captures<T>(captured));
1873  85 return null;
1874    }
1875   
1876    /**
1877    * Expect any boolean but captures it for later use.
1878    *
1879    * @param captured
1880    * Where the parameter is captured
1881    * @return <code>false</code>
1882    */
 
1883  10 toggle public static boolean captureBoolean(final Capture<Boolean> captured) {
1884  10 reportMatcher(new Captures<Boolean>(captured));
1885  10 return false;
1886    }
1887   
1888    /**
1889    * Expect any int but captures it for later use.
1890    *
1891    * @param captured
1892    * Where the parameter is captured
1893    * @return <code>0</code>
1894    */
 
1895  120 toggle public static int captureInt(final Capture<Integer> captured) {
1896  120 reportMatcher(new Captures<Integer>(captured));
1897  120 return 0;
1898    }
1899   
1900    /**
1901    * Expect any long but captures it for later use.
1902    *
1903    * @param captured
1904    * Where the parameter is captured
1905    * @return <code>0</code>
1906    */
 
1907  10 toggle public static long captureLong(final Capture<Long> captured) {
1908  10 reportMatcher(new Captures<Long>(captured));
1909  10 return 0;
1910    }
1911   
1912    /**
1913    * Expect any float but captures it for later use.
1914    *
1915    * @param captured
1916    * Where the parameter is captured
1917    * @return <code>0</code>
1918    */
 
1919  10 toggle public static float captureFloat(final Capture<Float> captured) {
1920  10 reportMatcher(new Captures<Float>(captured));
1921  10 return 0;
1922    }
1923   
1924    /**
1925    * Expect any double but captures it for later use.
1926    *
1927    * @param captured
1928    * Where the parameter is captured
1929    * @return <code>0</code>
1930    */
 
1931  10 toggle public static double captureDouble(final Capture<Double> captured) {
1932  10 reportMatcher(new Captures<Double>(captured));
1933  10 return 0;
1934    }
1935   
1936    /**
1937    * Expect any byte but captures it for later use.
1938    *
1939    * @param captured
1940    * Where the parameter is captured
1941    * @return <code>0</code>
1942    */
 
1943  10 toggle public static byte captureByte(final Capture<Byte> captured) {
1944  10 reportMatcher(new Captures<Byte>(captured));
1945  10 return 0;
1946    }
1947   
1948    /**
1949    * Expect any char but captures it for later use.
1950    *
1951    * @param captured
1952    * Where the parameter is captured
1953    * @return <code>0</code>
1954    */
 
1955  10 toggle public static char captureChar(final Capture<Character> captured) {
1956  10 reportMatcher(new Captures<Character>(captured));
1957  10 return 0;
1958    }
1959   
1960    /**
1961    * Expect any boolean but captures it for later use.
1962    *
1963    * @param captured
1964    * Where the parameter is captured
1965    * @return <code>0</code>
1966    *
1967    * @deprecated Because of harder erasure enforcement, doesn't compile in
1968    * Java 7
1969    */
 
1970  5 toggle @Deprecated
1971    public static boolean capture(final Capture<Boolean> captured) {
1972  5 return captureBoolean(captured);
1973    }
1974   
1975    /**
1976    * Expect any int but captures it for later use.
1977    *
1978    * @param captured
1979    * Where the parameter is captured
1980    * @return <code>0</code>
1981    *
1982    * @deprecated Because of harder erasure enforcement, doesn't compile in
1983    * Java 7
1984    */
 
1985  15 toggle @Deprecated
1986    public static int capture(final Capture<Integer> captured) {
1987  15 return captureInt(captured);
1988    }
1989   
1990    /**
1991    * Expect any long but captures it for later use.
1992    *
1993    * @param captured
1994    * Where the parameter is captured
1995    * @return <code>0</code>
1996    *
1997    * @deprecated Because of harder erasure enforcement, doesn't compile in
1998    * Java 7
1999    */
 
2000  5 toggle @Deprecated
2001    public static long capture(final Capture<Long> captured) {
2002  5 return captureLong(captured);
2003    }
2004   
2005    /**
2006    * Expect any float but captures it for later use.
2007    *
2008    * @param captured
2009    * Where the parameter is captured
2010    * @return <code>0</code>
2011    *
2012    * @deprecated Because of harder erasure enforcement, doesn't compile in
2013    * Java 7
2014    */
 
2015  5 toggle @Deprecated
2016    public static float capture(final Capture<Float> captured) {
2017  5 return captureFloat(captured);
2018    }
2019   
2020    /**
2021    * Expect any double but captures it for later use.
2022    *
2023    * @param captured
2024    * Where the parameter is captured
2025    * @return <code>0</code>
2026    *
2027    * @deprecated Because of harder erasure enforcement, doesn't compile in
2028    * Java 7
2029    */
 
2030  5 toggle @Deprecated
2031    public static double capture(final Capture<Double> captured) {
2032  5 return captureDouble(captured);
2033    }
2034   
2035    /**
2036    * Expect any byte but captures it for later use.
2037    *
2038    * @param captured
2039    * Where the parameter is captured
2040    * @return <code>0</code>
2041    *
2042    * @deprecated Because of harder erasure enforcement, doesn't compile in
2043    * Java 7
2044    */
 
2045  5 toggle @Deprecated
2046    public static byte capture(final Capture<Byte> captured) {
2047  5 return captureByte(captured);
2048    }
2049   
2050    /**
2051    * Expect any char but captures it for later use.
2052    *
2053    * @param captured
2054    * Where the parameter is captured
2055    * @return <code>0</code>
2056    *
2057    * @deprecated Because of harder erasure enforcement, doesn't compile in
2058    * Java 7
2059    */
 
2060  5 toggle @Deprecated
2061    public static char capture(final Capture<Character> captured) {
2062  5 return captureChar(captured);
2063    }
2064   
2065    /**
2066    * Switches the given mock objects (more exactly: the controls of the mock
2067    * objects) to replay mode. For details, see the EasyMock documentation.
2068    *
2069    * @param mocks
2070    * the mock objects.
2071    */
 
2072  1731 toggle public static void replay(final Object... mocks) {
2073  1731 for (final Object mock : mocks) {
2074  1755 getControl(mock).replay();
2075    }
2076    }
2077   
2078    /**
2079    * Resets the given mock objects (more exactly: the controls of the mock
2080    * objects). For details, see the EasyMock documentation.
2081    *
2082    * @param mocks
2083    * the mock objects.
2084    */
 
2085  165 toggle public static void reset(final Object... mocks) {
2086  165 for (final Object mock : mocks) {
2087  171 getControl(mock).reset();
2088    }
2089    }
2090   
2091    /**
2092    * Resets the given mock objects (more exactly: the controls of the mock
2093    * objects) and turn them to a mock with nice behavior. For details, see the
2094    * EasyMock documentation.
2095    *
2096    * @param mocks
2097    * the mock objects
2098    */
 
2099  11 toggle public static void resetToNice(final Object... mocks) {
2100  11 for (final Object mock : mocks) {
2101  11 getControl(mock).resetToNice();
2102    }
2103    }
2104   
2105    /**
2106    * Resets the given mock objects (more exactly: the controls of the mock
2107    * objects) and turn them to a mock with default behavior. For details, see
2108    * the EasyMock documentation.
2109    *
2110    * @param mocks
2111    * the mock objects
2112    */
 
2113  11 toggle public static void resetToDefault(final Object... mocks) {
2114  11 for (final Object mock : mocks) {
2115  11 getControl(mock).resetToDefault();
2116    }
2117    }
2118   
2119    /**
2120    * Resets the given mock objects (more exactly: the controls of the mock
2121    * objects) and turn them to a mock with strict behavior. For details, see
2122    * the EasyMock documentation.
2123    *
2124    * @param mocks
2125    * the mock objects
2126    */
 
2127  11 toggle public static void resetToStrict(final Object... mocks) {
2128  11 for (final Object mock : mocks) {
2129  11 getControl(mock).resetToStrict();
2130    }
2131    }
2132   
2133    /**
2134    * Verifies the given mock objects (more exactly: the controls of the mock
2135    * objects).
2136    *
2137    * @param mocks
2138    * the mock objects.
2139    */
 
2140  1247 toggle public static void verify(final Object... mocks) {
2141  1247 for (final Object mock : mocks) {
2142  1271 getControl(mock).verify();
2143    }
2144    }
2145   
2146    /**
2147    * Switches order checking of the given mock object (more exactly: the
2148    * control of the mock object) the on and off. For details, see the EasyMock
2149    * documentation.
2150    *
2151    * @param mock
2152    * the mock object.
2153    * @param state
2154    * <code>true</code> switches order checking on,
2155    * <code>false</code> switches it off.
2156    */
 
2157  21 toggle public static void checkOrder(final Object mock, final boolean state) {
2158  21 getControl(mock).checkOrder(state);
2159    }
2160   
2161    /**
2162    * Reports an argument matcher. This method is needed to define own argument
2163    * matchers. For details, see the EasyMock documentation.
2164    *
2165    * @param matcher
2166    */
 
2167  1366 toggle public static void reportMatcher(final IArgumentMatcher matcher) {
2168  1366 LastControl.reportMatcher(matcher);
2169    }
2170   
 
2171  3272 toggle private static MocksControl getControl(final Object mock) {
2172  3272 return ClassExtensionHelper.getControl(mock);
2173    }
2174   
2175    /**
2176    * Returns the arguments of the current mock method call, if inside an
2177    * <code>IAnswer</code> callback - be careful here, reordering parameters of
2178    * method changes the semantics of your tests.
2179    *
2180    * @return the arguments of the current mock method call.
2181    * @throws IllegalStateException
2182    * if called outside of <code>IAnswer</code> callbacks.
2183    */
 
2184  65 toggle public static Object[] getCurrentArguments() {
2185  65 final Invocation result = LastControl.getCurrentInvocation();
2186  65 if (result == null) {
2187  5 throw new IllegalStateException(
2188    "current arguments are only available when executing callback methods");
2189    }
2190  60 return result.getArguments();
2191    }
2192   
2193    /**
2194    * By default, a mock is thread safe (unless
2195    * {@link #NOT_THREAD_SAFE_BY_DEFAULT} is set). This method can change this
2196    * behavior. Two reasons are known for someone to do that: Performance or
2197    * dead-locking issues.
2198    *
2199    * @param mock
2200    * the mock to make thread safe
2201    * @param threadSafe
2202    * If the mock should be thread safe or not
2203    */
 
2204  11 toggle public static void makeThreadSafe(final Object mock, final boolean threadSafe) {
2205  11 getControl(mock).makeThreadSafe(threadSafe);
2206    }
2207   
2208    /**
2209    * Tell that the mock should be used in only one thread. An exception will
2210    * be thrown if that's not the case. This can be useful when mocking an
2211    * object that isn't thread safe to make sure it is used correctly in a
2212    * multithreaded environment. By default, no check is done unless
2213    * {@link #ENABLE_THREAD_SAFETY_CHECK_BY_DEFAULT} was set to true.
2214    *
2215    * @param mock
2216    * the mock
2217    * @param shouldBeUsedInOneThread
2218    * If the mock should be used in only one thread
2219    */
 
2220  10 toggle public static void checkIsUsedInOneThread(final Object mock, final boolean shouldBeUsedInOneThread) {
2221  10 getControl(mock).checkIsUsedInOneThread(shouldBeUsedInOneThread);
2222    }
2223   
2224    /**
2225    * Get the current value for an EasyMock property
2226    *
2227    * @param key
2228    * key for the property
2229    * @return the property value
2230    */
 
2231  55 toggle public static String getEasyMockProperty(final String key) {
2232  55 return EasyMockProperties.getInstance().getProperty(key);
2233    }
2234   
2235    /**
2236    * Set a property to modify the default EasyMock behavior. These properties
2237    * can also be set as System properties or in easymock.properties. This
2238    * method can then be called to overload them. For details and a list of
2239    * available properties see the EasyMock documentation.
2240    * <p>
2241    * <b>Note:</b> This method is static. Setting a property will change the
2242    * entire EasyMock behavior.
2243    *
2244    * @param key
2245    * property key
2246    * @param value
2247    * property value. A null value will remove the property
2248    * @return the previous property value
2249    */
 
2250  30 toggle public static String setEasyMockProperty(final String key, final String value) {
2251  30 return EasyMockProperties.getInstance().setProperty(key, value);
2252    }
2253   
2254    // ///CLOVER:OFF
 
2255    toggle protected EasyMock() { // Need to be protected since the Class extension extends it
2256    }
2257    // ///CLOVER:ON
2258    }